/**
 * Created by GanJc on 2015/9/10.
 */

'use strict';


// 选择<p>JavaScript</p>:
var js = document.getElementById("test-p");

// 选择<p>Python</p>,<p>Ruby</p>,<p>Swift</p>:
var arr = document.getElementById("test-div").children[1].getElementsByTagName("p");
console.log(arr);

// 选择<p>Haskell</p>:
var haskell = document.getElementById("test-div").children[2].getElementsByTagName("p")[1];

// 测试:
if (!js || js.innerText !== 'JavaScript') {
    alert('选择JavaScript失败!');
} else if (!arr || arr.length !== 3 || !arr[0] || !arr[1] || !arr[2] || arr[0].innerText !== 'Python' || arr[1].innerText !== 'Ruby' || arr[2].innerText !== 'Swift') {
    alert('选择Python,Ruby,Swift失败!');
} else if (!haskell || haskell.innerText !== 'Haskell') {
    alert('选择Haskell失败!');
} else {
    //alert('测试通过!');
}

var
    js = document.getElementById('js'),
    list = document.getElementById('list');
list.appendChild(js);

var
    list = document.getElementById('list'),
    haskell = document.createElement('p');
haskell.id = 'haskell';
haskell.innerText = 'Haskell啊啊啊啊';
list.appendChild(haskell);

var d = document.createElement('style');
d.setAttribute('type', 'text/css');
d.innerHTML = 'p { color: red }';
document.getElementsByTagName('head')[0].appendChild(d);

var
    list = document.getElementById('list'),
    ref = document.getElementById('python'),
    haskell = document.createElement('p');
haskell.id = 'haskell';
haskell.innerText = 'Haskell  insertBefore';
list.insertBefore(haskell, ref);

var list = document.getElementById('test-list');
list.removeChild(list.children[1])
list.removeChild(list.children[2])
list.removeChild(list.children[3])

